/**
 * @file main.cpp
 * @author 张奕欣 3190105655 (3190105655@zju.edu.cn)
 * @brief 
 * @version 0.1
 * @date 2022-10-05
 * 
 * @copyright Copyright (c) 2022
 * 
 */

#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include "DoubleLinkedList.h"
#include <string>

int main (int argc, char* argv []){
    List<int> Li;
    // 创建双链表
    for (int a = 1; a < 6; a = a + 1){
        Li.push_back(a);
    }
    cout << "The double linked list is :"<< " ";
    Li.print();

    cout << "The size is " << Li.size() << endl;
    cout << "The first number is " << Li.front() << endl;
    cout << "The last number is " << Li.back() << endl;

    // 插入一些数字
    Li.insert(Li.begin(),100);
    Li.insert(Li.end(),200);
    cout << "After inserting: ";
    Li.print();

    //删除前后的数字
    Li.pop_front();
    Li.pop_back();
    cout << "After deleting: ";
    Li.print();

    //查找数字是否存在
    cout << "Does 3 exist? "<< endl;
    auto itr = Li.find(3);
    
    //删除3，再查找3
    Li.erase(itr);
    Li.print();
    cout << "Does 3 exist? "<< endl;
    Li.find(3);

    //检查内存是否泄露
    _CrtDumpMemoryLeaks();

    return 0;
}
